import service from '@/utils/request'

export const useProductApi = (id: number) => {
  return service.get('/gps/product/info/' + id)
}

export const useProductSubmitApi = (dataForm: any) => {
  if (dataForm.id) {
    return service.put('gps/product/update', dataForm)
  } else {
    return service.post('gps/product/save', dataForm)
  }
}

// 获取通讯协议
export function getProtocol() {
  return service.get('/gps/product/allProts')
}
// 获取所有支持的功能
export function getAllFuncs() {
  return service.get('/gps/product/allFuncs')
}
// 添加设备类型
export function addDeviceType(data) {
  return service.post('/gps/product/save', data)
}

// 编辑设备类型
export function updateDeviceType(data) {
  return service.put('/gps/product/update', data)
}

// 获取用户所有的设备型号
export function getProductByUser() {
  return service.get('/gps/product/ownerByUser')
}
export function deleteProduct(id) {
  return service.delete(`/gps/product/delete/${id}`)
}
